#!/user/bin/env python3
# -*- coding: utf-8 -*-
"""
--------------------------------------
    Author:     JiChao_Song
    Date  :     2020/11/19 14:46
    Desc  :
--------------------------------------
"""
import requests
from config import *


class RequestsUtils:

    def __init__(self, excelData: list):
        """
        初始化
        :param excelData: excel一行数据
        """
        # 接口名称
        self.apiName = excelData[EXCEL_INFO.get('apiName')]
        # 接口地址
        self.apiPath = excelData[EXCEL_INFO.get('apiPath')]
        # 请求方法
        self.apiMethod = excelData[EXCEL_INFO.get('apiMethod')]
        # 请求参数
        self.apiParam = excelData[EXCEL_INFO.get('apiParam')]
        # 提取参数
        self.extract = excelData[EXCEL_INFO.get('extract')]
        # 断言字段
        self.assertPatam = excelData[EXCEL_INFO.get('assertPatam')]
        # 断言字段的值
        self.assertValue = excelData[EXCEL_INFO.get('assertValue')]
        # 是否执行
        self.isRun = excelData[EXCEL_INFO.get('isRun')]
        # 是否带请求头
        self.isHeaders = excelData[EXCEL_INFO.get('isHeaders')]

    def set_url(self):
        """
        设置url
        :return: url
        """
        return BASE_URL + self.apiPath

    def set_apiParam(self):
        """
        设置请求参数
        :return: apiParam
        """
        pass

    def set_extract(self):
        """
        设置提取参数
        :return:
        """
        pass

    def set_result(self):
        """
        构造返回结果
        :return: dict
        """
        pass

    def get_assert(self):
        """
        获取断言
        :return: bool
        """
        pass

    def post(self):
        return requests.post
